<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>snow </TITLE>
<META http-equiv="content-type" CONTENT="text/html;charset=gb2312">
<META NAME="Author" CONTENT="CZH;czh44@sohu.com">
<META NAME="Generator" CONTENT="EditPlus">
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
/*--------------------------------\
|  Authored by CZH;czh44@sohu.com |
\--------------------------------*/
var snow_size = new Array();
var snow_color = new Array();
var num= 50;		//雪花的个数
var	smallest = 5 ;	//雪花最小尺寸
var	largest = 30;	//确定最大尺寸
var dx = new Array();
var xp = new Array();
var yp = new Array();
var am = new Array();
var stx = new Array();
var sty = new Array();
var doc_width;
var doc_height;
//随机产生大小
function makeSize()
{	
	return smallest + Math.random()*largest;
}
//白色雪花
function makeColor1()
{
	for(i = 0; i < num; ++ i)
	{
		snow_color[i] = '#ffffff';
	}
}
//菜色雪花
function makeColor2()
{
	for(i = 0; i < num; ++ i)
	{
		A = Math.ceil(Math.random()*255);
		B = Math.ceil(Math.random()*255);
		C = Math.ceil(Math.random()*255);
		snow_color[i] = 'rgb('+A+','+B+','+C+')';
	}
}
//初始化参数
function init()
{
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
	makeColor2();		   //雪花颜色,若使用makeColor2()则为彩色
	for (i = 0; i < num; ++ i) 
	{	
    dx[i] = 0;							   // 水平坐标
    xp[i] = Math.random()*(doc_width-40);  // 水平位置
    yp[i] = Math.random()*doc_height;	   // 垂直位置
    am[i] = Math.random()*20;			   // 波动的幅度
	snow_size[i] = makeSize();			   // 雪花大小
    stx[i] = 0.02 + Math.random()/10;	   // 水平移动步距
    sty[i] = 0.7 + Math.random();		   // 垂直移动步距
    document.write("<div id='snow_"+ i +"' style='POSITION: absolute; Z-INDEX: eval(30"+ i +"); VISIBILITY: visible; TOP: 15px; LEFT: 15px;font-size:"+snow_size[i]+";color:"+snow_color[i]+"'>*</div>");    
	}
}

function snow() 
{
	for (i = 0; i < num; ++ i) 
	{ 
		yp[i] += sty[i];
		if (yp[i] > doc_height-50)	//如果到达底部
		{
		xp[i] = Math.random()*(doc_width-am[i]-20);
		yp[i] = 0;
        stx[i] = 0.02 + Math.random()/10;
        sty[i] = 0.7 + Math.random();
		}
		dx[i] += stx[i];
    document.getElementById("snow_"+i).style.top = yp[i];
    document.getElementById("snow_"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]);
    }
    setTimeout("snow()", 10);
}

//-->
</SCRIPT>
<BODY id='myBody' bgcolor="#bbbbbb">

</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
//注意函数调用的位置,要在元素定义之后
init();
snow();
//-->
</SCRIPT>
</HTML>
